<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('商户提现列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            状态：<select name="status">
                            <option value="">所有</option>
                            <option value="1">审核中</option>
                            <option value="2">被驳回</option>
                            <option value="3">已打款</option>
                        </select>
                        </li>
                        <li>
                            用户类型：<select name="remark">
                            <option value="">所有</option>
                            <option value="真人">真人</option>
                            <option value="假人">假人</option>
                        </select>
                        </li>
                        <li>
                            开户名：<input type="text" name="userName"/>
                        </li>
                        <li>
                            商户名称：<input type="text" name="businessNo"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="channel:businessCapital:add">
                <i class="fa fa-plus"></i> 申请提现
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()"
               shiro:hasPermission="channel:businessCapital:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var roleId = [[${roleId}]];
    var editFlag = [[${@permission.hasPermi('channel:businessCapital:edit')}]];
    var removeFlag = [[${@permission.hasPermi('channel:businessCapital:remove')}]];
    var prefix = ctx + "channel/businessCapital";
    var datastatus = [[${@dict.getType('channel_capital_status')}]];
    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "商户提现",
            sortName: "applyTime",
            sortOrder: "desc",
            showExport: true,
            columns: [{
                checkbox: true
            },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datastatus, value);
                    },
                    sortable: true
                },
                {
                    field: 'businessNo',
                    title: '商户名称',
                    sortable: true
                },
                {
                    field: 'remark',
                    title: '用户类型',
                    formatter: function (value) {
                        return value === '假人'? '<span style="color: red">假人</span>' : '真人'
                    },
                },
                {
                    field: 'applyTime',
                    title: '最近申请时间',
                    sortable: true
                },
                {
                    field: 'amount',
                    title: '提现金额',
                    sortable: true
                },
                {
                    field: 'fee',
                    title: '提现手续费',
                    sortable: true
                },
                {
                    field: 'realAmount',
                    title: '到款金额',
                    sortable: true
                },
                // {
                //     field: 'bankName',
                //     title: '银行名称',
                //     sortable: true
                // },
                {
                    field: 'bankNo',
                    title: '收款地址'
                },
                // {
                //     field: 'userName',
                //     title: '开户名',
                //     sortable: true
                // },
                // {
                //     field: 'remark',
                //     title: '备注',
                //     sortable: true
                // },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.capitalId + '\')"><i class="fa fa-edit"></i>查看</a> ');
                        if (roleId == 1 || roleId == 102 || roleId == 100) {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="changeStatus(\'' + row.capitalId + '\',\'2\')"><i class="fa fa-edit"></i>驳回</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="changeStatus(\'' + row.capitalId + '\',\'3\')"><i class="fa fa-edit"></i>放款</a> ');
                        }
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function changeStatus(id, status) {
        $.modal.confirm("确认进行此操作吗?", function () {
            var url = ctx + "channel/businessCapital/editStatus";
            var data = {id: id, status: status};
            $.operate.submit(url, "post", "json", data);
        });
    }

    // window.setInterval(function(){
    //     $.table.refresh();
    // }, 5000)
</script>
</body>
</html>